package com.feige.base.dto;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.feige.base.po.BaseAuditorPo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;


/**
 * @author feige
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class QueryAuditorBaseDto<T extends BaseAuditorPo> extends QueryBaseDto<T> {
    private static final long serialVersionUID = -4200452664177882007L;


    @ApiModelProperty(value = "创建者")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long createdBy;

    @ApiModelProperty(value = "更新者")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long modifiedBy;


    @Override
    public LambdaQueryWrapper<T> baseQueryWrapper(){
        LambdaQueryWrapper<T> queryWrapper = super.baseQueryWrapper();
        Long createdBy = this.getCreatedBy();
        if (createdBy != null){
            queryWrapper.ge(BaseAuditorPo::getCreatedBy, createdBy);
        }
        Long modifiedBy = this.getModifiedBy();
        if (modifiedBy != null){
            queryWrapper.ge(BaseAuditorPo::getModifiedBy, modifiedBy);
        }
        return queryWrapper;
    }

}
